package route

import (
	"cooke-home/stock-service/di"
	"log"

	"github.com/gin-gonic/gin"
)

var Router *gin.Engine

func InitRouter() {
	log.Println("开始初始化路由...")
	Router = gin.Default()

	Router.GET("/health", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"status": "ok",
		})
	})

	stockGroup := Router.Group("/stock")
	{
		stockGroup.POST("/save", di.StockController.Save)
		stockGroup.DELETE("/delete", di.StockController.Delete)
		stockGroup.PUT("/update", di.StockController.Update)
		stockGroup.GET("/get", di.StockController.Get)
		stockGroup.GET("/list", di.StockController.GetList)
		stockGroup.PUT("/clear", di.StockController.Clear)
		stockGroup.PUT("/minus", di.StockController.Minus)
	}

	log.Println("路由初始化完成")
}
